﻿using System;
using Dgg.LearnYourTools.NUnit.C_Assertions.Support;
using NUnit.Framework;

namespace Dgg.LearnYourTools.NUnit.C_Assertions.a_Exceptions
{
	[TestFixture]
	public class _018_TryCatch
	{
		[Test]
		public void RangeCtor_UnorderedBounds_Exception_TryCatch()
		{
			try
			{
				new Range<int>(5, 1);
			}
			catch (ArgumentOutOfRangeException) { }
		}

		[Test]
		public void RangeCtor_UnorderedBounds_Exception_TryCatchHandling()
		{
			try { new Range<int>(-1, -5); }
			catch (ArgumentOutOfRangeException ex)
			{
				Assert.That(ex.ParamName, Is.EqualTo("upperBound"));
				Assert.That(ex.ActualValue, Is.EqualTo(-5));
				Assert.That(ex.Message, Is.StringContaining("-5"));
			}
		}
	}
}
